#include "Locale.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Locale_classType = NULL;
VTable* Locale_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Bool equals(Obj? obj) */
Bool Locale_equals(Obj self, NullableObj obj)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.equals not implemented yet"));
}


/* Int hash() */
Int Locale_hash(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.hash not implemented yet"));
}


/* Str toStr() */
Str* Locale_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.toStr not implemented yet"));
}


/* Locale? fromStr(Str s, Bool checked) */
Locale* Locale_fromStr_1(Str* s)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.fromStr not implemented yet"));
}


/* Locale? fromStr(Str s, Bool checked) */
Locale* Locale_fromStr(Str* s, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.fromStr not implemented yet"));
}


/* Locale cur() */
Locale* Locale_cur(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.cur not implemented yet"));
}


/* Void setCur(Locale locale) */
void Locale_setCur(Locale* locale)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.setCur not implemented yet"));
}


/* This use(|This->Void| func) */
Locale* Locale_use(Locale* self, Func* func)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.use not implemented yet"));
}


/* Str lang() */
Str* Locale_lang(Locale* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.lang not implemented yet"));
}


/* Str? country() */
Str* Locale_country(Locale* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Locale.country not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Locale_initType(void)
{
  if (Locale_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Locale_initVTable();
    Type* type = Type_new("Locale", baseType, vtable, sizeof(Locale), sizeof(LocaleVTable));
    Type_registerMethodImplementation(type, "country", Locale_country, 0);
    Type_registerMethodImplementation(type, "cur", Locale_cur, 0);
    Type_registerMethodImplementation(type, "equals", Locale_equals, 1);
    Type_registerMethodImplementation(type, "fromStr", Locale_fromStr_1, 1);
    Type_registerMethodImplementation(type, "fromStr", Locale_fromStr, 2);
    Type_registerMethodImplementation(type, "hash", Locale_hash, 0);
    Type_registerMethodImplementation(type, "lang", Locale_lang, 0);
    Type_registerMethodImplementation(type, "setCur", Locale_setCur, 1);
    Type_registerMethodImplementation(type, "toStr", Locale_toStr, 0);
    Type_registerMethodImplementation(type, "use", Locale_use, 1);
    Locale_classType = type;
    Locale_initStatic();
  }
  return Locale_classType;
}


VTable* Locale_initVTable(void)
{
  if (Locale_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(LocaleVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->equals = Locale_equals;
    ((FanObjVTable*)vtable)->hash = Locale_hash;
    ((FanObjVTable*)vtable)->toStr = Locale_toStr;
    Locale_classVTable = vtable;
  }
  return Locale_classVTable;
}


void Locale_initStatic(void)
{
}
